#include "xor.hpp"

void		Xor::solve()
{
  unsigned int				cpt = 0;
  unsigned int				nb_entries = 0;
  AObject* elem;

  for (unsigned int i = 0; i < this->_cond.size(); ++i)
    {
      ++nb_entries;
      elem = this->_cond.front();
      this->_cond.pop();
      elem->solve();
      if (elem->getState() == TRUE)
	{
	  ++cpt;
	}
      if (elem->getState() == UNDEFINED)
	{
	  this->_state = UNDEFINED;
	  this->_cond.push(elem);
	  return ;
	}
      this->_cond.push(elem);
    }
  if (nb_entries > 1 && cpt == 1)
    this->_state = TRUE;
  else
    this->_state = FALSE;
}
